package com.tbvtc.agriculturalcreditchainserver2025.controller.admin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tbvtc.agriculturalcreditchainserver2025.entity.EnvironmentData;
import com.tbvtc.agriculturalcreditchainserver2025.service.IEnvironmentDataService;
import com.tbvtc.agriculturalcreditchainserver2025.utils.RUtils;
import com.tbvtc.agriculturalcreditchainserver2025.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

@RequestMapping("/env")
@RestController
@Tag(name = "环境")
public class EnvironmentController {
    @Resource
    private IEnvironmentDataService environmentDataService;

    /**
     * 温度列表
     * @param date
     * @return
     */
    @GetMapping("/getData")
    @Operation(summary ="获取某一天温度列表")
    public Result getData(String date) {
        LocalDate parse = LocalDate.parse(date);
        return RUtils.success( environmentDataService.getData(parse));
    }

    /**
     * 湿度列表
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/getHumidity")
    @Operation(summary ="获取某一天时间的湿度列表")
    public Result getHumidity(String date) {
        LocalDate parse = LocalDate.parse(date);
        return RUtils.success(  environmentDataService.getHumidity(parse));
    }

    /**
     * 光照
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/getIllumination")
    @Operation(summary ="获一天取某时间的光照列表")
    public Result getIllumination(String date) {
        LocalDate parse = LocalDate.parse(date);
        return RUtils.success(  environmentDataService.getIllumination(parse));
    }


    @GetMapping("/getScore")
    @Operation(summary ="一个阶段的分数")
    public Result getScore(String begin,String end) {
        LocalDate beginParse = LocalDate.parse(begin);
        LocalDate endParse = LocalDate.parse(end);
        return RUtils.success(environmentDataService.getScore(beginParse,endParse));
    }

}
